﻿<UserControl x:Class="BookManagementWpfApplication.Views.UserControl.ListBookView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"   
             xmlns:vm="clr-namespace:BookManagementWpfApplication.ViewModels"
             xmlns:vu="clr-namespace:BookManagementWpfApplication.Views.UserControl"
             xmlns:converter="clr-namespace:BookManagementWpfApplication.Converters"
             
             FontFamily="Tahoma" FontSize="15"
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="970">
    
    <UserControl.Resources>
        <vm:ListBookViewModel x:Key="listBookViewModel" />
        <converter:BookStatusConvert x:Key="bookStatusConvert" />
        <converter:DateToYearConvert x:Key="dateToYearConvert" />
    </UserControl.Resources>
    
    <ScrollViewer DataContext="{Binding Source={StaticResource listBookViewModel}}">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="60" />
            <RowDefinition Height="60" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <StackPanel Name="stackPanel1" Orientation="Horizontal">
            <TextBlock Height="29" Name="textBlock1" Text="รายชื่อหนังสือ" FontWeight="Bold" FontSize="22" Margin="20,0,0,0" TextAlignment="Left" />
        </StackPanel>
        
        <StackPanel Name="stackPanel2" Margin="0,60,0,0" Grid.RowSpan="2" Orientation="Horizontal">
            <TextBlock Height="25" Name="textBlock2" Text="ค้นหาหนังสือ : " Margin="20,5,0,0" FontWeight="Bold" />
            <TextBox Height="25" Name="filterTextBoxListBook" Width="262" Margin="5,0,0,0" KeyUp="filterTextBoxListBook_KeyUp" />
            <TextBlock Height="25" Name="textBlock3" Text="สถานะหนังสือ : " FontWeight="Bold" Margin="15,5,0,0" />
            <CheckBox Content="ยืม" Height="25" Margin="5,5,0,0" IsChecked="{Binding Path=BorrowStatusCheck, Mode=TwoWay}" />
            <CheckBox Content="ว่าง" Height="25" Margin="15,5,0,0" IsChecked="{Binding Path=ReturnStatusCheck, Mode=TwoWay}" />
            <CheckBox Content="ชำรุด" Height="25" Margin="15,5,0,0" IsChecked="{Binding Path=DamageStatusCheck, Mode=TwoWay}" />
            <CheckBox Content="สูญหาย" Height="25" Margin="15,5,0,0" IsChecked="{Binding Path=LostStatusCheck, Mode=TwoWay}" />
            <CheckBox Content="ส่งซ่อม" Height="25" Margin="15,5,0,0" IsChecked="{Binding Path=RepairStatusCheck, Mode=TwoWay}" />
            <CheckBox Content="จัดซื้อใหม่" Height="25" Margin="15,5,0,0" IsChecked="{Binding Path=BuyNewStatusCheck, Mode=TwoWay}" />            
        </StackPanel>

        <DataGrid AutoGenerateColumns="False" Grid.Row="2" Name="allListBookDataGrid" Margin="12,0,10,48" ItemsSource="{Binding Path=BookICV}" Background="#FFA1DAF2" AlternatingRowBackground="#FF2BDAFF">
            <DataGrid.Columns>                
                <DataGridTextColumn Header="รหัสหนังสือ" Width="Auto" Binding="{Binding Path=BookCode}" />
                <DataGridTextColumn Header="ชื่อหนังสือ" Width="Auto" Binding="{Binding Path=BookName}" />
                <DataGridTextColumn Header="ผู้แต่ง/ผู้แปล" Width="auto" Binding="{Binding Path=Writer}" />
                <DataGridTextColumn Header="ประเภทหนังสือ" Width="auto" Binding="{Binding Path=BookType}" />
                <DataGridTextColumn Header="ปีที่จัดซื้อ" Width="auto" Binding="{Binding Path=DateOfPurchase, Converter={StaticResource dateToYearConvert}}" />
                <DataGridTextColumn Header="ISBN" Width="auto" Binding="{Binding Path=ISBN}" />
                <DataGridTextColumn Header="สถานะ" Width="auto" Binding="{Binding Path=BookStatus, Converter={StaticResource bookStatusConvert}}" />
                <DataGridTextColumn Header="หมายเหตุ" Width="250" Binding="{Binding Path=RemarkOfBook}" />
            </DataGrid.Columns>
        </DataGrid>
<!--การดูข้อมุล(คลิกขวา)ต้องให้ดูครบทุกฟิดที่ตั้งไว้ทั้งหมด คือดูข้อมูลโดยละเอียดนั้นเอง
        คลิกขวา แสดงเฉพาะปีจัดซื้อ พ.ศ.-->
        <Rectangle Height="1" Name="rectangle1" Stroke="Black" Width="Auto" Margin="10,54,10,5" />
        
    </Grid>
    </ScrollViewer>
</UserControl>
